package com.kitty.game.team;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.enter.ReqOtherMoveTo;
import com.kitty.game.role.model.Role;
import com.kitty.game.team.service.TeamService;
import com.kitty.mina.annotation.RequestMapping;
import com.kitty.mina.cache.SessionUtils;
import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
//后写
import com.kitty.game.team.message.ReqAccept;
import com.kitty.game.team.message.ReqChangeTeamLeader;
import com.kitty.game.team.message.ReqCheckPlayer;
import com.kitty.game.team.message.ReqKickOutTeam;
import com.kitty.game.team.message.ReqLeaveTempTeam;
import com.kitty.game.team.message.ReqOperTeleportItem;
import com.kitty.game.team.message.ReqQuitTeam;
import com.kitty.game.team.message.ReqRefreshRequestInfo;
import com.kitty.game.team.message.ReqReject;
import com.kitty.game.team.message.ReqRequestJoin;
import com.kitty.game.team.message.ReqReturnTeam;
import com.kitty.game.team.message.ReqShift;


@Controller
public class TeamController {
    Logger logger = LoggerFactory.getLogger(TeamController.class);

    @Autowired
    TeamService teamService;

    /**
     * 跟随队长
     */
    @RequestMapping
    public void shift(IoSession session, ReqShift reqShift) {
        teamService.shift(session, reqShift);
    }

    /**
     * 打开组队界面
     */
    @RequestMapping
    public void refreshRequestInfo(IoSession session, ReqRefreshRequestInfo reqRefreshRequestInfo) {
        teamService.refreshRequestInfo(session, reqRefreshRequestInfo);
    }

    /**
     * 踢出队伍
     */
    @RequestMapping
    public void transLeader(IoSession session, ReqKickOutTeam reqKickOutTeam) {
        teamService.kickOutTeam(session, reqKickOutTeam);

    }

    /**
     * 暂离
     */
    @RequestMapping
    public void leaveTempTeam(IoSession session, ReqLeaveTempTeam reqLeaveTempTeam) {
        teamService.leaveTemp(session, reqLeaveTempTeam);
    }

    /**
     * 归队
     */
    @RequestMapping
    public void returnTeam(IoSession session, ReqReturnTeam reqguiduiTeam) {
        Role role =SessionUtils.getRoleBySession(session);
        teamService.returnTeam(role);
    }

    /**
     * 一键召集
     */
    @RequestMapping
    public void operTeleportItem(IoSession session, ReqOperTeleportItem reqOperTeleportItem) {
        teamService.operTeleport(session, reqOperTeleportItem);
    }

    /**
     * 组队移动包
     */
    @RequestMapping
    public void leaderMove(IoSession session, ReqOtherMoveTo reqOtherMoveTo) {
        teamService.otherMove(session, reqOtherMoveTo);
    }

    /**
     * 更换队长
     */
    @RequestMapping
    public void changeTeamLeader(IoSession session, ReqChangeTeamLeader reqChangeTeamLeader) {
        teamService.changeLeader(session, reqChangeTeamLeader);

    }

    /**
     * 查看玩家信息
     */
    @RequestMapping
    public void check(IoSession session, ReqCheckPlayer reqCheckPlayer) {
        SpringUtils.getRoleService().checkRoleInfo(session, reqCheckPlayer);
    }

    /**
     * 离开队伍
     */
    @RequestMapping
    public void leave(IoSession session, ReqQuitTeam reqQuitTeam) {
        Role role = SessionUtils.getRoleBySession(session);
        if (role == null) {
            return;
        }
        teamService.leave(role,false);
    }

    /**
     * 接受邀请
     */
    @RequestMapping
    public void accept(IoSession session, ReqAccept reqAccept) {
        teamService.accept(session, reqAccept);
    }

    /**
     * 拒绝
     */
    @RequestMapping
    public void reject(IoSession session, ReqReject reqReject) {
        teamService.reject(session, reqReject);
    }

    /**
     * 请求加入
     */
    @RequestMapping
    public void requestJoin(IoSession session, ReqRequestJoin requestJoin) {
        teamService.requestJoin(session, requestJoin);
    }
}
